<%@ page language="java" contentType="text/html; charset=utf8"
         pageEncoding="utf8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta content="text/html; charset=utf8" http-equiv="Content-Type" >
    <title><spring:message text="Auto" /></title>
</head>
<body>

<jsp:include page="menu/menu.jsp" />

<h2><spring:message text="Auto" /></h2>

<form:form method="post" action="autoadd" commandName="auto">
    <table>
        <tr>
            <th><form:label path="mark">
                <spring:message text="mark"/>
            </form:label></th>
            <th><form:label path="regNumber">
                <spring:message text="regNumber"/>
            </form:label></th>
            <th><form:label path="ownerId.id">
                <spring:message text="ownerId.id"/>
            </form:label></th>
            <th><form:label path="other">
                <spring:message text="other"/>
            </form:label></th>
        </tr>
        <tr>
            <td><form:input path="mark"/></td>
            <td><form:input path="regNumber" cssClass="unique-input"/></td>
            <td><form:input path="ownerId.id"/></td>
            <td><form:input path="other"/></td>
        </tr>
    </table>

    <tr>
        <td colspan="2"><input type="submit" value="<spring:message text="Add"/>"/></td>
    </tr>

</form:form>

<h3><spring:message text="List auto"/></h3>
<c:if test="${!empty autoList}">
    <table class="data">
        <tr>
            <th><spring:message text="#"/></th>
            <th><spring:message text="mark"/></th>
            <th><spring:message text="regNumber"/></th>
            <th><spring:message text="ownerId.id"/></th>
            <th><spring:message text="lastName"/></th>
            <th><spring:message text="firstName"/></th>
            <th><spring:message text="other"/></th>
            <th>&nbsp;</th>
        </tr>
        <c:forEach items="${autoList}" var="auto">
            <tr>
                <td>${auto.id}</td>
                <td>${auto.mark}</td>
                <td>${auto.regNumber}</td>
                <td>${auto.ownerId.id}</td>
                <td>${auto.ownerId.lastName}</td>
                <td>${auto.ownerId.firstName}</td>
                <td>${auto.other}</td>
                <td><a href="autodel/${auto.id}"><spring:message text="Delete"/></a></td>
            </tr>
        </c:forEach>
    </table>
</c:if>

</body>
</html>